import axios from 'axios';
import type{
  AxiosInstance,
  AxiosResponse,
  AxiosError,
  InternalAxiosRequestConfig,
}from 'axios';
const service:AxiosInstance = axios.create({
  // 我们就可以在环境变量中改变axios的baseURL
  baseURL:import.meta.env.VITE_APP_API_BASEURL,
  timeout: 15000,
})
//axios实现拦截请求
service.interceptors.request.use(
  (config:InternalAxiosRequestConfig)=>{
    return config;
  },
  (error:AxiosError)=>{
    return Promise.reject(error);
  }
);
//axios实现拦截响应
service.interceptors.response.use(
  (response:AxiosResponse)=>{
    return response;
  },
  (error:AxiosError)=>{
    return Promise.reject(error);
  }
);
export default service;
